# -*-encoding: utf-8 -*-

import PySQLPool
import threading
import MySQLdb
from Connection import mConn

class MySqlPoolThread(threading.Thread):

    #sql = ""
    #query = None
    #param = None

    def __init__(self, sql, *param):
        threading.Thread.__init__(self)
        self.sql = sql
        self.param = param
    def run(self):
        self.query = PySQLPool.getNewQuery(mConn)
        self.query.commitOnEnd = True
        #print self.sql + " | " + self.param[0]
        self.query.Query(self.sql, self.param)
    def showResult(self):
        return self.query.record   
    def showAffectedRows(self):
        return self.query.affectedRows

#updateSQL = "UPDATE user_image_info SET path = 'www888' WHERE md5 = '096241b4c7bf2e59f5b3e5e9f2bfcaed' AND user_id = '6'"
##updateSQL = '''
##INSERT INTO user_image_info (md5, path, user_id) VALUES('aaa', 'bbb', 4)
##'''
#
#print 1
#mQuery = PySQLPool.getNewQuery(mConn)
#mQuery.commitOnEnd = True
#print 2
#mQuery.Query(updateSQL)
##mQuery.execute(updateSQL)
#print 3
#print mQuery.affectedRows
#print dir(mQuery)
#print mQuery.commitOnEnd
#for row in mQuery.record:
#    print row['ID']
